Ejemplo: Curvas de indiferencia#

# !pip install plotly
import numpy as np
import pandas as pd

import matplotlib.pyplot as plt
import seaborn as sns
# plt.style.use('seaborn')
plt.rcParams.update({
    "text.usetex": True,
    "font.family": "sans-serif",
    "font.sans-serif": ["Computer Modern"]})
plt.clf()
%matplotlib inline

import plotly.io as pio
import plotly.express as px
import plotly.offline as py
import plotly.graph_objects as go
<Figure size 640x480 with 0 Axes>
delta = 0.025
x = np.arange(1, 10, delta)
y = np.arange(1, 10, delta)

X, Y = np.meshgrid(x, y)
Z = X**0.5 * Y**0.5
fig, ax = plt.subplots()
CS = ax.contour(X, Y, Z, 20)
ax.set_aspect('equal', adjustable='box')
ax.clabel(CS, inline=True, fontsize=10)
ax.set_title('Lineas de contorno')
Text(0.5, 1.0, 'Lineas de contorno')
../_images/cbc2bdb40d6cd99d271935951a2eee0bedcc6890af8d4e62f206d679c32069d5.png
fig = go.Figure(data=[go.Surface(z=Z)])
fig.update_traces(contours_z=dict(show=True, usecolormap=True,
                                  highlightcolor="limegreen", project_z=True))
fig.update_layout(title='Curvas de indiferencia', autosize=False,
                  scene_camera_eye=dict(x=1.87, y=0.88, z=-0.64),
                  width=500, height=500,
                  margin=dict(l=65, r=50, b=65, t=90)
)
fig.show()